package com.hl.sfzy.controller;

import com.hl.sfzy.entity.SearchQuestion;
import com.hl.sfzy.entity.SearchTest;
import com.hl.sfzy.service.SearchQuestionService;
import com.hl.sfzy.service.SearchTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/search/tests")
public class SearchTestController {
    @Autowired
    private SearchTestService searchTestService;

    @GetMapping("/getTests")
    public ResponseEntity<Map<String, Object>> searchTests(@RequestParam String query) {
        List<SearchTest> tests = searchTestService.searchTests(query);
        Map<String, Object> response = new HashMap<>();
        response.put("tests", tests);
        return ResponseEntity.ok(response);

    }
}
